package file

import (
	"os"

	library ".."
)

// File 本地文件读取
type File struct {
	library.FileExtend
	file *os.File
}

// Open 打开
func (F *File) Open(name string) error {
	file, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE, 0766)
	if err != nil {
		return err
	}
	F.file = file
	return nil
}

// Write .
func (F *File) Write(b []byte) (n int, err error) {
	return F.file.Write(b)
}

// WriteAt .
func (F *File) WriteAt(b []byte, off int64) (n int, err error) {
	return F.file.WriteAt(b, off)
}

// Read .
func (F *File) Read(b []byte) (n int, err error) {
	return F.file.Read(b)
}

// ReadAt .
func (F *File) ReadAt(b []byte, off int64) (n int, err error) {
	return F.file.ReadAt(b, off)
}

// Close 关闭文件
func (F *File) Close() error {
	return F.file.Close()
}
